<template>
  <template v-for="menu in userMenu">
    <el-sub-menu
      v-if="
        menu.children &&
        menu.children.length > 0 &&
        menu.children[0].menuType == 1
      "
      :key="menu._id"
      :index="menu.path"
    >
      <template #title>
        <template v-if="menu.icon === 'Setting'">
          <el-icon><Setting /></el-icon>
        </template>
        <template v-else="menu.icon === 'Promotion'">
          <el-icon><Promotion /></el-icon>
        </template>
        
        <span>{{ menu.menuName }}</span>
      </template>
      <tree-menu :userMenu="menu.children" />
    </el-sub-menu>
    <el-menu-item
      v-else-if="menu.menuType == 1"
      :index="menu.path"
      :key="menu._id"
      >{{ menu.menuName }}</el-menu-item
    >
  </template>
</template>

<script setup>
defineProps({
  userMenu: {
    type: Array,
    default() {
      return []
    },
  },
})
</script>

<style></style>
